package com.iwhalecloud.uncc;

import com.iwhalecloud.uncc.mq.producer.MqProducerManager;
import com.iwhalecloud.uncc.redis.RedisManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * @Description
 * @Author xu.dangling
 * @Date 2021/4/1
 */
@Component
public class CommonBeanInitialization {

    @Autowired
    private RedisManager redisManager;
    @Autowired
    private MqProducerManager mqProducerManager;

    @Bean
    @LoadBalanced
    public RestTemplate balancedRestTemplate() {
        return new RestTemplate();
    }

    public void init(){
        // 初始化redis
        redisManager.init();
        // 初始化生产者
        mqProducerManager.init();
    }
}
